package com.example.demo.auth

import org.springframework.stereotype.Component
import org.springframework.web.method.HandlerMethod
import javax.servlet.http.HttpServletRequest

@Component
class AuthBus(private val verifyHandlers: List<IAuthHandler>) {
    fun verify(request: HttpServletRequest, handlerImpl: HandlerMethod): AuthResult {
        for (handler in verifyHandlers) {
            if (handler.match(request, handlerImpl)) return handler.verifyUser(request,handlerImpl) else continue
        }
        val authResult = AuthResult()
        authResult.isVerify = false
        authResult.message = "unsupport"
        return authResult
    }
}